Dart SDK Target
The Target
class provides a way to define settings and behaviors that are specific to each compilation target (such as web, mobile, server).
This allows Dart to be truly cross-platform, enabling the same codebase to be compiled and run effectively in different environments.
Each target has a unique name, identifying the specific platform or configuration it represents (e.g., iOS, Android, Web).
A global Map targets
in pkg/kernel/lib/target/targets.dart
contains all the targets:
final Map<String, _TargetBuilder> targets = <String, _TargetBuilder>{
'none': (TargetFlags flags) => new NoneTarget(flags),
};
In the compilation process, installAdditionalTargets
(tool/_fasta/additional_targets.dart:20
) will set all the supported targets.
Note: installAdditionalTargets
is also the first of the compilation, so finding its usage will get all the compiling methods in the Dart SDK.
Library Management
- Required Libraries (
extraRequiredLibraries
): This is a list of essential libraries for the target, excluding the defaultdart:core
. It ensures that the necessary libraries are loaded and available during compilation. - Platform-Specific Libraries (
extraRequiredLibrariesPlatform
): These are additional libraries needed specifically for compiling the Dart platform itself. This feature is useful for maintaining compatibility and functionality across different versions or configurations. - Indexed Libraries (
extraIndexedLibraries
): These libraries are indexed for the CoreTypes index, helping in the efficient resolution of core types and classes, excluding some specific core libraries.
All the Targets
- Target
- NoTransformationsMixin
- TestVmTarget
- TestTarget
- TestDevCompilerTarget
- TestWasmTarget
- TestDart2jsTarget
- TestVmTarget
- Dart2jsTarget
- HookInDart2jsTarget
- TestDart2jsTarget
- Dart2jsSummaryTarget
- VmTarget
- TestVmTarget
- HookInVmTarget
- TestVmTarget
- FlutterTarget
- HookInFlutterTarget
- DartRunnerTarget
- FlutterRunnerTarget
- DevCompilerTarget
- HookInDevCompilerTarget
- TestDevCompilerTarget
- WasmTarget
- TestWasmTarget
- NoneTarget
- TargetWrapper
- TestTargetWrapper
- TargetWrapper
- SummaryMixin
- Dart2jsSummaryTarget
- TestTargetMixin
- TestDevCompilerTarget
- TestVmTarget
- TestWasmTarget
- TestDart2jsTarget
- TestTargetWrapper
- NoTransformationsMixin
本文作者:Maeiee
本文链接:Dart SDK Target
版权声明:如无特别声明,本文即为原创文章,版权归 Maeiee 所有,未经允许不得转载!
喜欢我文章的朋友请随缘打赏,鼓励我创作更多更好的作品!